package cuiyt.collection.randomitem.setiterator;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author cyt
 * @create 2020-10-03 下午 10:24
 */
public class test {
    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();
        set.add(2);
        set.add(3);
        set.add(4);
        set.add(5);
        Iterator<Integer> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        for (Integer integer : set) {
            System.out.println(integer);
        }

        Object[] toArray = set.toArray();
        for (Object o : toArray) {
            System.out.println(o);
        }
    }
}
